package ioc

import (
	"github.com/spf13/viper"
	"xorm.io/xorm"
)

type Config struct {
	DSN    string
	Driver string
}

func DataBaseInitialization(viper *viper.Viper) *xorm.Engine {
	var cfg = Config{
		Driver: viper.GetString("db.driver"),
		DSN:    viper.GetString("db.dsn"),
	}
	engine, err := xorm.NewEngine(cfg.Driver, cfg.DSN)
	if err != nil {
		panic(err)
	}
	return engine
}
